home *** CD-ROM | disk | FTP | other *** search
/ Personal Computer World 2009 February / PCWFEB09.iso / Software / Resources / Chat & Communication / Digsby build 37 / digsby_setup.exe / lib / gui / uberwidgets / ucontrol.pyo (.txt) < prev    next >
Python Compiled Bytecode  |  2008-10-13  |  6KB  |  138 lines

  1. # Source Generated with Decompyle++
  2. # File: in.pyo (Python 2.5)
  3.  
  4. from gui.skin.skinobjects import Margins
  5. from gui.textutil import default_font
  6. from gui.skin import get as skinget
  7. import wx
  8. from gui.uberwidgets.keycatcher import KeyCatcher
  9.  
  10. class UControl(wx.PyControl):
  11.     
  12.     def __init__(self, parent, skinkey, id = -1, label = '', pos = wx.DefaultPosition, size = wx.DefaultSize, style = wx.NO_BORDER):
  13.         self.Padding = wx.Size()
  14.         wx.PyControl.__init__(self, parent, id = id, style = style)
  15.         self.skinkey = skinkey
  16.         self.margins = Margins((0, 0, 0, 0))
  17.         self._native = False
  18.         self.Font = default_font()
  19.         self.SetBackgroundStyle(wx.BG_STYLE_CUSTOM)
  20.         self.Bind(wx.EVT_ERASE_BACKGROUND, (lambda e: pass))
  21.         self.Bind(wx.EVT_PAINT, self._UControl__paint)
  22.         self.SetLabel(label)
  23.         self.SetInitialSize(size)
  24.         self.InheritAttributes()
  25.  
  26.     
  27.     def KeyCatcher(self):
  28.         
  29.         try:
  30.             return self.Top._keycatcher
  31.         except AttributeError:
  32.             k = self.Top._keycatcher = KeyCatcher(self.Top)
  33.             return k
  34.  
  35.  
  36.     KeyCatcher = property(KeyCatcher)
  37.     
  38.     def UpdateSkin(self):
  39.         self.skin = skinget(self.skinkey)
  40.         self.Padding = wx.Size(*skinget(self.skinkey + '.Padding', (0, 0)))
  41.         self.SetMargins(skinget(self.skinkey + '.Margins', (lambda : Margins((0, 0, 0, 0)))))
  42.  
  43.     
  44.     def BindHover(self, callback = None):
  45.         self.Hover = False
  46.         self.hover_callback = callback
  47.         self.Bind(wx.EVT_ENTER_WINDOW, self._UControl__enter)
  48.         self.Bind(wx.EVT_LEAVE_WINDOW, self._UControl__leave)
  49.  
  50.     
  51.     def BindFocus(self, callback = None):
  52.         self.Focus = False
  53.         self.focus_callback = callback
  54.         self.Bind(wx.EVT_SET_FOCUS, self._UControl__setfocus)
  55.         self.Bind(wx.EVT_KILL_FOCUS, self._UControl__killfocus)
  56.  
  57.     
  58.     def __setfocus(self, e):
  59.         e.Skip()
  60.         self.Focus = True
  61.         if self.focus_callback is not None:
  62.             self.focus_callback(True)
  63.         
  64.  
  65.     
  66.     def __killfocus(self, e):
  67.         e.Skip()
  68.         self.Focus = False
  69.         if self.focus_callback is not None:
  70.             self.focus_callback(False)
  71.         
  72.  
  73.     
  74.     def __enter(self, e):
  75.         e.Skip()
  76.         self.Hover = True
  77.         if self.hover_callback is not None:
  78.             self.hover_callback(True)
  79.         
  80.  
  81.     
  82.     def __leave(self, e):
  83.         e.Skip()
  84.         self.Hover = False
  85.         if self.hover_callback is not None:
  86.             self.hover_callback(False)
  87.         
  88.  
  89.     
  90.     def DrawBackground(self, dc, rect):
  91.         self.BackgroundRegion.Draw(dc, rect)
  92.  
  93.     
  94.     def GetMargins(self):
  95.         return self.margins
  96.  
  97.     
  98.     def SetMargins(self, margins):
  99.         self.margins = margins
  100.         self.InvalidateBestSize()
  101.  
  102.     Margins = property(GetMargins, SetMargins)
  103.     
  104.     def __paint(self, e):
  105.         if self._native:
  106.             return wx.PaintDC(self)
  107.         
  108.         dc = wx.BufferedPaintDC(self)
  109.         rect = self.ClientRect
  110.         if rect.width and rect.height:
  111.             self.DrawBackground(dc, rect)
  112.             m = self.margins
  113.             rect.Offset(m[:2])
  114.             rect.SetSize((rect.Width - m.left - m.right, rect.Height - m.top - m.bottom))
  115.             self.Draw(dc, rect)
  116.         
  117.  
  118.     
  119.     def DrawFocusRect(self, dc, rect):
  120.         dc.SetBrush(wx.TRANSPARENT_BRUSH)
  121.         dc.SetPen(wx.Pen(wx.BLACK, style = wx.DOT))
  122.         dc.DrawRectangleRect(rect)
  123.  
  124.     
  125.     def DoGetBestSize(self):
  126.         m = self.margins
  127.         s = self.GetContentSize()
  128.         s.IncBy(m.left, m.top)
  129.         s.IncBy(m.right, m.bottom)
  130.         self.CacheBestSize(s)
  131.         return s
  132.  
  133.     
  134.     def ShouldInheritColours(self):
  135.         return False
  136.  
  137.  
  138.